load("//bzl:cpp_library.bzl", "cpp_library")

package(default_visibility = ["//visibility:public"])

cpp_library(
    name = "cache_locality",
    srcs = ["CacheLocality.cpp"],
    hdrs = ["CacheLocality.h"],
    linkopts = select({
        "@platforms//os:linux": ["-ldl"],
        "//conditions:default": [],
    }),
    deps = [
        "//folly:indestructible",
        "//folly:likely",
        "//folly:memory",
        "//folly:portability",
        "//folly:scope_guard",
        "//folly/detail:static_singleton_manager",
        "//folly/hash",
        "//folly/lang:align",
        "//folly/lang:exception",
        "//folly/portability:unistd",
        "//folly/synchronization:atomic_ref",
        "//folly/system:thread_id",
        "@fmt",
        "@glog",
    ],
)

cpp_library(
    name = "atomic_shared_ptr",
    hdrs = [
        "AtomicSharedPtr.h",
        "detail/AtomicSharedPtr-detail.h",
    ],
    deps = [
        "//folly:packed_sync_ptr",
        "//folly/lang:safe_assert",
        "//folly/memory:sanitize_leak",
        "//folly/synchronization:atomic_struct",
        "//folly/synchronization:atomic_util",
        "//folly/synchronization/detail:atomic_utils",
    ],
)

cpp_library(
    name = "core_cached_shared_ptr",
    hdrs = ["CoreCachedSharedPtr.h"],
    deps = [
        ":cache_locality",
        "//folly:cpp_attributes",
        "//folly:portability",
        "//folly:unit",
        "//folly/synchronization:hazptr",
    ],
)

cpp_library(
    name = "concurrent_hash_map",
    hdrs = [
        "ConcurrentHashMap.h",
        "detail/ConcurrentHashMap-detail.h",
    ],
    deps = [
        "//folly:optional",
        "//folly/container:heterogeneous_access",
        "//folly/container/detail:f14_mask",
        "//folly/lang:exception",
        "//folly/synchronization:hazptr",
    ],
)

cpp_library(
    name = "dynamic_bounded_queue",
    hdrs = [
        "DynamicBoundedQueue.h",
    ],
    deps = [
        ":cache_locality",
        ":unbounded_queue",
        "@glog",
    ],
)

cpp_library(
    name = "priority_unbounded_queue_set",
    hdrs = [
        "PriorityUnboundedQueueSet.h",
    ],
    deps = [
        ":unbounded_queue",
        "//folly:memory",
        "//folly/lang:align",
    ],
)

cpp_library(
    name = "unbounded_queue",
    hdrs = [
        "UnboundedQueue.h",
    ],
    deps = [
        ":cache_locality",
        "//folly:constexpr_math",
        "//folly:optional",
        "//folly:traits",
        "//folly/lang:align",
        "//folly/synchronization:hazptr",
        "//folly/synchronization:saturating_semaphore",
        "//folly/synchronization:wait_options",
        "//folly/synchronization/detail:spin",
        "@glog",
    ],
)

cpp_library(
    name = "deadlock_detector",
    srcs = ["DeadlockDetector.cpp"],
    hdrs = [
        "DeadlockDetector.h",
    ],
    deps = [
        "//folly:executor",
        "//folly/executors:queue_observer",
    ],
)

cpp_library(
    name = "thread_cached_synchronized",
    hdrs = ["ThreadCachedSynchronized.h"],
    deps = [
        "//folly:shared_mutex",
        "//folly:thread_local",
        "//folly:utility",
        "//folly/lang:access",
        "//folly/synchronization:lock",
        "//folly/synchronization:relaxed_atomic",
    ],
)

cpp_library(
    name = "process_local_unique_id",
    srcs = ["ProcessLocalUniqueId.cpp"],
    hdrs = ["ProcessLocalUniqueId.h"],
    deps = [
        "//folly:likely",
        "//folly/synchronization:relaxed_atomic",
    ],
)

cpp_library(
    name = "singleton_relaxed_counter",
    hdrs = [
        "SingletonRelaxedCounter.h",
    ],
    deps = [
        "//folly:likely",
        "//folly:portability",
        "//folly:synchronized",
        "//folly:utility",
        "//folly/detail:static_singleton_manager",
        "//folly/detail:thread_local_globals",
        "//folly/lang:safe_assert",
        "//folly/synchronization:atomic_ref",
    ],
)
